/**************************************
Creates Table OB2 and obtains estimates for 
difference in coefs for Figure 2
******************************************/

clear
**Update path as needed
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Figure2"
log using "figure2_tableob2.log"

**This data file is created in the R sytax for this figure
use "figure2_pooled.dta"
set more off

/****Some Initial Cleaning*****/
label var treat "Treatment Condition"
label var support01 "Policy Support"
label var stereo "Policy Stereotypicality"
label var experiment "Experiment"

/*****Models******/
eststo clear
eststo: regress support01 i.treat##i.stereo i.experiment
eststo: regress support01 i.treat##i.stereo if experiment == 1
eststo: regress support01 i.treat##i.stereo if experiment == 2

/*****Table******/
esttab using "figure2_table.rtf", replace ///
	onecell label nobaselevels b(2) se star(* 0.05 ** 0.01 *** 0.001) ///
	mtitles("Pooled" "Exp 2." "Exp. 3") ///
	title("{\b Table OB2:} Figure 2 Analyses") ///
	addnotes("The baseline category for the cue treatment is the No Cue condition. The base category for policy stereotypicality is counter-stereotypical. The base for experiment is Experiment 2.")

/******Calculate marginal effect, diff in diff*******/

*Model 1: Stereotypical
regress support01 i.treat##i.stereo i.experiment
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:2.stereo] - _b[3.treat:2.stereo]
	parmest, label saving("pooled_stereotypical", replace)
	
*Model 1: Couner-Stereotypical
regress support01 i.treat##i.stereo i.experiment
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:1bn.stereo] - _b[3.treat:1bn.stereo]
	parmest, label saving("pooled_counterstereotypical", replace)
	
*Model 2: Stereotypical
regress support01 i.treat##i.stereo if experiment == 1
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:2.stereo] - _b[3.treat:2.stereo]
	parmest, label saving("exp2_stereotypical", replace)
	
*Model 2: Couner-Stereotypical
regress support01 i.treat##i.stereo if experiment == 1
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:1bn.stereo] - _b[3.treat:1bn.stereo]
	parmest, label saving("exp2_counterstereotypical", replace)
	
*Model 3: Stereotypical
regress support01 i.treat##i.stereo if experiment == 2
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:2.stereo] - _b[3.treat:2.stereo]
	parmest, label saving("exp3_stereotypical", replace)
	
*Model 3: Couner-Stereotypical
regress support01 i.treat##i.stereo if experiment == 2
	margins, dydx(treat) by(stereo) post coeflegend
	lincomest _b[2.treat:1bn.stereo] - _b[3.treat:1bn.stereo]
	parmest, label saving("exp3_counterstereotypical", replace)
	
	
log close
